<template>
  <section>
    <van-radio-group v-model="radio">
      <van-cell-group>
        <van-cell :key="item" :title="item" data-index="index" v-for="item in flows" clickable @click="radio = item">
          <van-radio :name="item" />
        </van-cell>
      </van-cell-group>
    </van-radio-group>
  </section>
</template>
<script>

import "../../../../util/compatibles";
import {RadioGroup,Radio,Cell,CellGroup} from "vant/es";
import common from "../../../../util/index";
// import {mapState, mapMutations} from 'vuex'

export default {
  components: {
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
  },
  watch:{
    radio:function(newValue,oldValue){
      if(newValue !== oldValue){
        this.setPrefs("local.flow",newValue);
      }
    },
  },
  data() {
    return {
      radio:"仅WiFi",
      flows: [
        "仅WiFi",
        "WiFi和流量",
      ],
    };
  },
  mounted(){
    window.apiready = ()=>{
      this.radio = this.getPrefsSync("local.flow") || this.radio;
    };
  },
  methods   : {
    ck(e){
      console.log(e);
    },
    ...common.methods,
  },
};
</script>
<style lang="scss">

</style>
